package 代码随想录.数组.区间和;

import java.util.Scanner;

class Solution {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        
        int[] vec = new int[n];
        int p[] = new int[n];
        
        for(int i = 0; i < n; i++) {
            vec[i] = scanner.nextInt();
        } 
        while(scanner.hasNextInt()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            
            int sum = 0;
            if(a == 0) {
                sum = p[b];
            }else {
                sum = p[b]-p[a-1];
            }
            System.out.println(sum);
        } // while
        scanner.close();
        
    } // main  
} // Solution
